clear 

** read in .dta file **

use "${clean}/who_counts_analysis.dta", clear

** Event Study plot, Alt. Dichotimization, 1945-1962 **

gen byte D = (FOR_MAX == 1)
gen `:type year' Dyear = cond(D, YOB, 1950)

reghdfe MOB b1950.Dyear ec_total, absorb(Arabic Female geo2_ma YOB reg_fe) cluster(geo2_ma) noconstant
matrix list e(b)
label variable Dyear "year"

local plotopts ytitle("Estimate and 95% Conf. Int.") title("DiD Max,Effect on Registration")
coefplot, vertical yline(0) ciopts(recast(rcap)) xlabel(,angle(45)) `plotopts'
graph save "${output}/graphs/MOB_HDID_PRE_MAX.gph", replace
graph export "${output}/graphs/MOB_HDID_PRE_MAX.png", replace

reghdfe Schooling b1950.Dyear ec_total, absorb(Arabic Female geo2_ma YOB reg_fe) cluster(geo2_ma) noconstant
matrix list e(b)
label variable Dyear "year"

local plotopts ytitle("Estimate and 95% Conf. Int.") title("DiD Max,Effect on Formal Schooling")
coefplot, vertical yline(0) ciopts(recast(rcap)) xlabel(,angle(45)) `plotopts'
graph save "${output}/graphs/Schooling_HDID_PRE_MAX.gph", replace
graph export "${output}/graphs/Schooling_HDID_PRE_MAX.png", replace

reghdfe EDU_YRS b1950.Dyear ec_total, absorb(Arabic Female geo2_ma YOB reg_fe) cluster(geo2_ma) noconstant
matrix list e(b)
label variable Dyear "year"

local plotopts ytitle("Estimate and 95% Conf. Int.") title("DiD Max,Effect on Formal Schooling, Years")
coefplot, vertical yline(0) ciopts(recast(rcap)) xlabel(,angle(45)) `plotopts'
graph save "${output}/graphs/YRS_HDID_PRE_MAX.gph", replace
graph export "${output}/graphs/YRS_HDID_PRE_MAX.png", replace

reghdfe French_Lit b1950.Dyear ec_total, absorb(Arabic Female geo2_ma YOB reg_fe) cluster(geo2_ma) noconstant
matrix list e(b)
label variable Dyear "year"

local plotopts ytitle("Estimate and 95% Conf. Int.") title("DiD Max, Effect on French Literacy")
coefplot, vertical yline(0) ciopts(recast(rcap)) xlabel(,angle(45)) `plotopts'
graph save "${output}/graphs/LIT_HDID_PRE_MAX.gph", replace
graph export "${output}/graphs/LIT_HDID_PRE_MAX.png", replace

** Output Graphs ** 

graph combine "${output}/graphs/MOB_HDID_PRE_MAX.gph" "${output}/graphs/Schooling_HDID_PRE_MAX.gph" 
graph save "${output}/graphs/PRE_Honest1_MAX.gph", replace
graph export "${output}/graphs/Figure11A_A.png", replace

graph combine "${output}/graphs/YRS_HDID_PRE_MAX.gph" "${output}/graphs/LIT_HDID_PRE_MAX.gph"
graph save "${output}/graphs/PRE_Honest2_MAX.gph", replace
graph export "${output}/graphs/Figure11A_B.png", replace
